package com.wc._16届国特冲刺营._06数据结构_三队列神技.整数删除;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2025/5/10 11:35
 * @description
 * https://www.lanqiao.cn/courses/51805/learning/?id=4072940&compatibility=false
 */
public class Main {
    /**
     * 思路：
     * 双向链表删除
     * 堆排序
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 500010;
    static long[] a = new long[N];
    static int[] l = new int[N], r = new int[N];
    static PriorityQueue<long[]> q = new PriorityQueue<>((o1, o2) -> {
        if (o1[0] == o2[0]) return Long.compare(o1[1], o2[1]);
        return Long.compare(o1[0], o2[0]);
    });
    static int n, k;

    public static void main(String[] args) {
        n = sc.nextInt();
        k = sc.nextInt();
        for (int i = 0; i <= n + 1; i++) {
            l[i] = i - 1;
            r[i] = i + 1;
        }
        for (int i = 1; i <= n; i++) a[i] = sc.nextInt();
        for (int i = 1; i <= n; i++) {
            q.add(new long[]{a[i], i});
        }

        while (k-- > 0 && !q.isEmpty()) {
            long[] t = q.poll();
            long x = t[0];
            int i = (int) t[1];
            if (x == a[i]) {
                a[l[i]] += x;
                a[r[i]] += x;
                // 删除 i
                l[r[i]] = l[i];
                r[l[i]] = r[i];
            } else {
                k++;
                q.add(new long[]{a[i], i});
            }
        }
        for (int i = r[0]; i <= n; i = r[i]) {
            out.print(a[i] + " ");
        }
        out.println();
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}

